package ai.汉诺塔;

public class HanoiTower {

    /**
     * 移动函数
     * @param n     当前还有n次移动
     * @param a     从a盘拿走
     * @param b     经过b盘中转
     * @param c     到达c盘
     * @param ui    界面
     */
    public void move(int n, Tower a, Tower b, Tower c, UI ui) {
        if (0 == n) {
            ui.freshUI();
            return;
        }
        move(n - 1, a, c, b, ui);
        ui.freshUI();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        c.getTower().push(a.getTower().pop());
        move(n - 1, b, a, c, ui);
    }
}
